package com.prs.crm.dao.taskmanager.impl;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.dao.taskmanager.TaskAllotDao;
import com.prs.crm.domain.taskmanager.TaskAllot;

public class TaskAllotDaoImpl extends BaseDaoImpl<TaskAllot>implements TaskAllotDao{

	@SuppressWarnings("unchecked")
	@Override
	public List<TaskAllot> getAllTaskAllot() {
		Criteria criteria=this.getSession().createCriteria(TaskAllot.class);
		return criteria.list();
	}

	@Override
	public Collection<TaskAllot> findTaskAllotById(String ids) {	
		try{
		TaskAllot taskAllot=new TaskAllot();
		Collection<TaskAllot> taskAllots=new ArrayList<TaskAllot>();
		ids=taskAllot.getConsultPersonId();
		String str2[]=ids.split(",");
		for (String id : str2) {		
			taskAllot.setConsultPersonId(id);
			taskAllots.add(taskAllot);
			System.out.println(id);
		}
		return taskAllots;
	}catch (NumberFormatException e) {
		e.printStackTrace();
		return null;
		}
//		Criteria criteria=this.getSession().createCriteria(TaskAllot.class);
//		
//		return criteria.list();
	}

	@SuppressWarnings("unchecked")
	@Override
	public Collection<TaskAllot> getRootTaskAllot() {
		Criteria criteria =this.getSession().createCriteria(TaskAllot.class);
		criteria.add(Restrictions.isNull("parent"));
		return criteria.list();
	}

}
